import React, { useState } from 'react';
import { Radio, Space } from 'antd';

interface TabProps {
  onTabChange?: (tabValue: string) => void;
}

const Tab: React.FC<TabProps>= ({onTabChange}) => {
  const [tab, setTab] = useState('全部');

  const handleTabChange = (e:any)=>{
    const newTab = e.target.value;
    setTab(newTab);
    //调用父组件传递的回调函数
    if (onTabChange){
      onTabChange(newTab);
    }
  }
  return (
      <Space align="center" >
        题型：
        <Radio.Group
          value={tab}
          onChange={handleTabChange}
        >
          <Radio.Button value="全部">全部</Radio.Button>
          <Radio.Button value="单选题">单选题</Radio.Button>
          <Radio.Button value="多选题">多选题</Radio.Button>
          <Radio.Button value="编程题">编程题</Radio.Button>
        </Radio.Group>
      </Space>
  );
};

export default Tab;